const {SocketD} = require("@noear/socket.d")

async function init() {
    const eventListener = await SocketD.newEventListener().doOnMessage((s, m) => {
        //监听所有消息（可能不需要）
        console.log("doOnMessage", m.event(), m.dataAsString());
    }).doOnClose(session => {
        console.log("onClose");
    }).doOnError((session, error) => {
        console.log("doOnError");
    });

    const session = await SocketD.createClient("sd:ws://127.0.0.1:1205?wsClientId=123")
        .listen(eventListener)
        .open()

    console.log("SocketD.createClient finish");
}

init()
